/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Abel
 */

//este codigo crea Hilo a traves de un Extends de Thread
/*public class Hilo extends Thread{
    public Hilo (String str){
        super(str);
    }
    public void run(){
        for (int i = 0; i < 10; i++) {
            System.out.println(i+" "+getName());
            try {
                Thread.sleep((int)(Math.random()*1000));
            } catch (Exception e) {
                System.out.println("Error de Sleep");
            }
        }
    }
}
class MultiHilo{
    public static void main(String[] args) {
        new Hilo("Primer Hilo").start();
        new Hilo("segundo Hilo").start();
    }
}

*/

//Este codigo crea un Hilo a traves de implements Runable
public class Hilo implements Runnable{
    private String nombre;
    public Hilo(String str){
        this.nombre=str;
    }
    public String getName(){
        return this.nombre;
    }
    public void run(){
        for (int i = 0; i < 10; i++) {
            System.out.println(i+" "+getName());
            try {
                Thread.sleep((int)(Math.random()*1000));
            } catch (Exception e) {}
            
        }
    }
}

 class MultiHilo{
     public static void main(String[] args) {
         new Thread(new Hilo("primer Hilo")).start();
         new Thread(new Hilo("Segundo Hilo")).start();
     }
 } 
nbhbhh
        jbhbhb
bvgbv
//hola mundo lksoldjsodjksndjks
